// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#ifndef __MAINFRM_H__
#define __MAINFRM_H__

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#define FILE_MENU_POSITION	0
#define RECENT_MENU_POSITION	6
#define POPUP_MENU_POSITION	0


#include "view.h"

LPCTSTR g_lpcstrMRURegKey = _T("Software\\Microsoft\\WTL Samples\\BmpView");
LPCTSTR g_lpcstrApp = _T("BmpView");



class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>,
		public CMessageFilter, public CIdleHandler
#ifndef _WIN32_WCE
	//	, public CPrintJobInfo
#endif // _WIN32_WCE
{
public:
	DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

#ifndef _WIN32_WCE
	//CCommandBarCtrl m_CmdBar;
//	CRecentDocumentList m_mru;
	//CMruList m_list;
#endif // _WIN32_WCE
//	CBitmapView m_view;

	TCHAR m_szFilePath[MAX_PATH];

	// printing support
#ifndef _WIN32_WCE
	//CPrinter m_printer;
	//CDevMode m_devmode;
	//CPrintPreviewWindow m_wndPreview;
	//CEnhMetaFile m_enhmetafile;
	//RECT m_rcMargin;
	//bool m_bPrintPreview;
#endif // _WIN32_WCE


	CMainFrame() 
#ifndef _WIN32_WCE
	//	: m_bPrintPreview(false)
#endif // _WIN32_WCE
	{
#ifndef _WIN32_WCE
		//::SetRect(&m_rcMargin, 1000, 1000, 1000, 1000);
	//	m_printer.OpenDefaultPrinter();
		//m_devmode.CopyFromPrinter(m_printer);
#endif // _WIN32_WCE
		m_szFilePath[0] = 0;
	}

	virtual BOOL PreTranslateMessage(MSG* pMsg)
	{
		if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
			return TRUE;

		return FALSE;
	//	return m_view.PreTranslateMessage(pMsg);
	}

	virtual BOOL OnIdle()
	{
//		BOOL bEnable = !m_view.m_bmp.IsNull();
#ifndef _WIN32_WCE
	//	UIEnable(ID_FILE_PRINT, bEnable);
	//	UIEnable(ID_FILE_PRINT_PREVIEW, bEnable);
	//	UISetCheck(ID_FILE_PRINT_PREVIEW, m_bPrintPreview);
#endif // _WIN32_WCE
	///	UIEnable(ID_EDIT_COPY, bEnable);
	//	UIEnable(ID_EDIT_PASTE, ::IsClipboardFormatAvailable(CF_BITMAP));
	//	UIEnable(ID_EDIT_CLEAR, bEnable);
	//	UIEnable(ID_VIEW_PROPERTIES, bEnable);
#ifndef _WIN32_WCE
	//	UISetCheck(ID_RECENT_BTN, m_list.IsWindowVisible());
#endif // _WIN32_WCE
#ifndef WIN32_PLATFORM_PSPC
	//	UIUpdateToolBar();
#endif // WIN32_PLATFORM_PSPC

		return FALSE;
	}


	BEGIN_MSG_MAP_EX(CMainFrame)
		MSG_WM_CREATE(OnCreate)

#if 0

		COMMAND_ID_HANDLER_EX(ID_FILE_OPEN, OnFileOpen)
#ifndef _WIN32_WCE
		COMMAND_RANGE_HANDLER_EX(ID_FILE_MRU_FIRST, ID_FILE_MRU_LAST, OnFileRecent)
		COMMAND_ID_HANDLER_EX(ID_RECENT_BTN, OnRecentButton)
#endif // _WIN32_WCE
#ifndef _WIN32_WCE
		COMMAND_ID_HANDLER_EX(ID_FILE_PRINT, OnFilePrint);
		COMMAND_ID_HANDLER_EX(ID_FILE_PAGE_SETUP, OnFilePageSetup)
		COMMAND_ID_HANDLER_EX(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview);
#endif // _WIN32_WCE
		COMMAND_ID_HANDLER_EX(ID_APP_EXIT, OnFileExit)
		COMMAND_ID_HANDLER_EX(ID_EDIT_COPY, OnEditCopy)
		COMMAND_ID_HANDLER_EX(ID_EDIT_PASTE, OnEditPaste)
		COMMAND_ID_HANDLER_EX(ID_EDIT_CLEAR, OnEditClear)
#ifndef _WIN32_WCE
		COMMAND_ID_HANDLER_EX(ID_VIEW_TOOLBAR, OnViewToolBar)
#endif // _WIN32_WCE
#ifndef WIN32_PLATFORM_PSPC
		COMMAND_ID_HANDLER_EX(ID_VIEW_STATUS_BAR, OnViewStatusBar)
#endif // WIN32_PLATFORM_PSPC



		COMMAND_ID_HANDLER_EX(ID_VIEW_PROPERTIES, OnViewProperties)
		COMMAND_ID_HANDLER_EX(ID_APP_ABOUT, OnAppAbout)

#endif // if 0

		CHAIN_MSG_MAP(CUpdateUI<CMainFrame>)
		CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame>)
	END_MSG_MAP()

	BEGIN_UPDATE_UI_MAP(CMainFrame)

#if 0

#ifndef _WIN32_WCE
		UPDATE_ELEMENT(ID_FILE_PRINT, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
		UPDATE_ELEMENT(ID_FILE_PRINT_PREVIEW, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
#endif // _WIN32_WCE
		UPDATE_ELEMENT(ID_EDIT_COPY, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
		UPDATE_ELEMENT(ID_EDIT_PASTE, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
		UPDATE_ELEMENT(ID_EDIT_CLEAR, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
#ifndef _WIN32_WCE
		UPDATE_ELEMENT(ID_VIEW_TOOLBAR, UPDUI_MENUPOPUP)
#endif // _WIN32_WCE
#ifndef WIN32_PLATFORM_PSPC
		UPDATE_ELEMENT(ID_VIEW_STATUS_BAR, UPDUI_MENUPOPUP)
#endif // WIN32_PLATFORM_PSPC
		UPDATE_ELEMENT(ID_VIEW_PROPERTIES, UPDUI_MENUPOPUP | UPDUI_TOOLBAR)
		UPDATE_ELEMENT(ID_RECENT_BTN, UPDUI_TOOLBAR)

#endif // if 0

	END_UPDATE_UI_MAP()

	int OnCreate(LPCREATESTRUCT /*lpCreateStruct*/)
	{

		CMessageLoop* pLoop = _Module.GetMessageLoop();
		ATLASSERT(pLoop != NULL);
		pLoop->AddMessageFilter(this);
		pLoop->AddIdleHandler(this);

		return 0;
	}


	void OnFileExit(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/)
	{
		PostMessage(WM_CLOSE);
	}

	void OnFileOpen(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wnd*/)
	{

	}


};

#endif // __MAINFRM_H__
